package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcDemo06 {
    public static void main(String[] args) {
        try (
                Connection connection = DbUtil.getConnection();
                ){
            Statement statement = connection.createStatement();
            String str = "SELECT count(*) '总人数'\n" +
                    "FROM class c \n" +
                    "JOIN student s ON c.id = s.class_id\n" +
                    "WHERE C.name = '1年级1班'";
            ResultSet rs  = statement.executeQuery(str);
            while (rs.next()){
                int count = rs.getInt("总人数");
                System.out.println("人数为："+count);


            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
